package com.deram.ctin.rest.web.controller.web;

import com.deram.ctin.common.bean.Page;
import com.deram.ctin.common.bean.PageResult;
import com.deram.ctin.dependencies.rest.base.BaseController;
import com.deram.ctin.rest.web.model.web.WebInvestmentEnterSearchModel;
import com.deram.ctin.serv.business.api.*;
import com.deram.ctin.serv.business.entity.BusinessInfo;
import com.deram.ctin.serv.business.entity.BusinessInvestment;
import com.deram.ctin.serv.business.filter.BusinessInvestmentFilter;
import com.deram.ctin.serv.enter.api.EnterInfoApi;
import com.deram.ctin.serv.enter.entity.EnterInfo;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhangcm
 * @version 1.0, 2017/9/28
 */
@Api(tags = {"web - 企业对外投资接口"})
@RestController
@RequestMapping("/web/enter")
public class WebEnterInvestInfoController extends BaseController {

    @Autowired
    private EnterInfoApi enterInfoApi;

    @Autowired
    private BusinessInfoApi businessInfoApi;

    @Autowired
    private BusinessInvestmentApi businessInvestmentApi;

    @ApiOperation(value = "对外投资")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path"),
    })
    @GetMapping("/investment/{id}")
    public PageResult<BusinessInvestment> investment(@PathVariable Long id, Page page){
        BusinessInvestmentFilter enterInfoFilter = new BusinessInvestmentFilter();
        enterInfoFilter.setEnterId(id);
        return businessInvestmentApi.searchWithEnter(enterInfoFilter,page.getPageNo(),page.getPageSize());
    }
}
